home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / Menus.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  26.9 KB  |  840 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Menus.h
  3.  
  4.      Contains:    Menu Manager Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __MENUS__
  18. #define __MENUS__
  19.  
  20. #ifndef __APPLEEVENTS__
  21. #include <AppleEvents.h>
  22. #endif
  23. #ifndef __CONDITIONALMACROS__
  24. #include <ConditionalMacros.h>
  25. #endif
  26. #ifndef __EVENTS__
  27. #include <Events.h>
  28. #endif
  29. #ifndef __PROCESSES__
  30. #include <Processes.h>
  31. #endif
  32. #ifndef __TEXTCOMMON__
  33. #include <TextCommon.h>
  34. #endif
  35. #ifndef __MACTYPES__
  36. #include <MacTypes.h>
  37. #endif
  38. #ifndef __QUICKDRAW__
  39. #include <Quickdraw.h>
  40. #endif
  41.  
  42.  
  43.  
  44. #if PRAGMA_ONCE
  45. #pragma once
  46. #endif
  47.  
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52. #if PRAGMA_IMPORT
  53. #pragma import on
  54. #endif
  55.  
  56. #if PRAGMA_STRUCT_ALIGN
  57.     #pragma options align=mac68k
  58. #elif PRAGMA_STRUCT_PACKPUSH
  59.     #pragma pack(push, 2)
  60. #elif PRAGMA_STRUCT_PACK
  61.     #pragma pack(2)
  62. #endif
  63.  
  64. /*——————————————————————————————————————————————————————————————————————————————————————*/
  65. /*    • Gestalt and Errors (Mac OS 8.5 and later)                                            */
  66. /*——————————————————————————————————————————————————————————————————————————————————————*/
  67.  
  68. enum {
  69.     gestaltMenuMgrAttr            = FOUR_CHAR_CODE('menu'),        /* If this Gestalt exists, the Mac OS 8.5 Menu Manager is installed*/
  70.     gestaltMenuMgrPresent        = 1
  71. };
  72.  
  73.  
  74. enum {
  75.     menuPropertyInvalid            = -5603,
  76.     menuPropertyNotFoundErr        = -5604
  77. };
  78.  
  79.  
  80. /*——————————————————————————————————————————————————————————————————————————————————————*/
  81. /*    • Menu Constants                                                                     */
  82. /*——————————————————————————————————————————————————————————————————————————————————————*/
  83.  
  84. enum {
  85.     noMark                        = 0                                /*mark symbol for MarkItem*/
  86. };
  87.  
  88.  
  89. enum {
  90.                                                                 /* menu defProc messages */
  91.     kMenuDrawMsg                = 0,
  92.     kMenuChooseMsg                = 1,
  93.     kMenuSizeMsg                = 2,
  94.     kMenuDrawItemMsg            = 4,
  95.     kMenuCalcItemMsg            = 5,
  96.     kMenuThemeSavvyMsg            = 7,                            /* is your MDEF theme-savvy?  If so, return hex 7473 in the whichItem parameter*/
  97.     mDrawMsg                    = 0,
  98.     mChooseMsg                    = 1,
  99.     mSizeMsg                    = 2,
  100.     mDrawItemMsg                = 4,
  101.     mCalcItemMsg                = 5
  102. };
  103.  
  104.  
  105. enum {
  106.     kThemeSavvyMenuResponse        = 0x7473
  107. };
  108.  
  109.  
  110. enum {
  111.     textMenuProc                = 0,
  112.     hMenuCmd                    = 27,                            /*itemCmd == 0x001B ==> hierarchical menu*/
  113.     hierMenu                    = -1,                            /*a hierarchical menu - for InsertMenu call*/
  114.     mPopUpMsg                    = 3,                            /*menu defProc messages - place yourself*/
  115.     mctAllItems                    = -98,                            /*search for all Items for the given ID*/
  116.     mctLastIDIndic                = -99                            /*last color table entry has this in ID field*/
  117. };
  118.  
  119. /* Constants for use with MacOS 8.0 (Appearance 1.0) and later*/
  120.  
  121. enum {
  122.     kMenuStdMenuProc            = 63,
  123.     kMenuStdMenuBarProc            = 63
  124. };
  125.  
  126.  
  127. enum {
  128.     kMenuNoModifiers            = 0,                            /* Mask for no modifiers*/
  129.     kMenuShiftModifier            = (1 << 0),                        /* Mask for shift key modifier*/
  130.     kMenuOptionModifier            = (1 << 1),                        /* Mask for option key modifier*/
  131.     kMenuControlModifier        = (1 << 2),                        /* Mask for control key modifier*/
  132.     kMenuNoCommandModifier        = (1 << 3)                        /* Mask for no command key modifier*/
  133. };
  134.  
  135.  
  136. enum {
  137.     kMenuNoIcon                    = 0,                            /* No icon*/
  138.     kMenuIconType                = 1,                            /* Type for ICON*/
  139.     kMenuShrinkIconType            = 2,                            /* Type for ICON plotted 16 x 16*/
  140.     kMenuSmallIconType            = 3,                            /* Type for SICN*/
  141.     kMenuColorIconType            = 4,                            /* Type for cicn*/
  142.     kMenuIconSuiteType            = 5,                            /* Type for Icon Suite*/
  143.     kMenuIconRefType            = 6                                /* Type for Icon Ref*/
  144. };
  145.  
  146.  
  147.  
  148. /*——————————————————————————————————————————————————————————————————————————————————————*/
  149. /*    • Menu Structures                                                                     */
  150. /*——————————————————————————————————————————————————————————————————————————————————————*/
  151.  
  152. struct MenuInfo {
  153.     short                             menuID;
  154.     short                             menuWidth;
  155.     short                             menuHeight;
  156.     Handle                             menuProc;
  157.     long                             enableFlags;
  158.     Str255                             menuData;
  159. };
  160. typedef struct MenuInfo                    MenuInfo;
  161.  
  162. typedef MenuInfo *                        MenuPtr;
  163. typedef MenuPtr *                        MenuHandle;
  164. /* MenuRef is obsolete.  Use MenuHandle.  Or don’t.  It’s all the same to us.  We’re here to serve.*/
  165. typedef MenuHandle                         MenuRef;
  166.  
  167. struct MCEntry {
  168.     short                             mctID;                        /*menu ID.  ID = 0 is the menu bar*/
  169.     short                             mctItem;                    /*menu Item. Item = 0 is a title*/
  170.     RGBColor                         mctRGB1;                    /*usage depends on ID and Item*/
  171.     RGBColor                         mctRGB2;                    /*usage depends on ID and Item*/
  172.     RGBColor                         mctRGB3;                    /*usage depends on ID and Item*/
  173.     RGBColor                         mctRGB4;                    /*usage depends on ID and Item*/
  174.     short                             mctReserved;                /*reserved for internal use*/
  175. };
  176. typedef struct MCEntry                    MCEntry;
  177. typedef MCEntry *                        MCEntryPtr;
  178.  
  179. typedef MCEntry                         MCTable[1];
  180. typedef MCEntry *                        MCTablePtr;
  181. typedef MCTablePtr *                    MCTableHandle;
  182.  
  183. struct MenuCRsrc {
  184.     short                             numEntries;                    /*number of entries*/
  185.     MCTable                         mcEntryRecs;                /*ARRAY [1..numEntries] of MCEntry*/
  186. };
  187. typedef struct MenuCRsrc                MenuCRsrc;
  188. typedef MenuCRsrc *                        MenuCRsrcPtr;
  189. typedef MenuCRsrcPtr *                    MenuCRsrcHandle;
  190. #if TARGET_OS_WIN32
  191. /* QuickTime 3.0 */
  192.  
  193. struct MenuAccessKeyRec {
  194.     short                             count;
  195.     long                             flags;
  196.     unsigned char                     keys[1];
  197. };
  198. typedef struct MenuAccessKeyRec            MenuAccessKeyRec;
  199.  
  200. typedef MenuAccessKeyRec *                MenuAccessKeyPtr;
  201. typedef MenuAccessKeyPtr *                MenuAccessKeyHandle;
  202. EXTERN_API_C( void )
  203. SetMenuItemHotKey                (MenuHandle             menu,
  204.                                  short                     itemID,
  205.                                  char                     hotKey,
  206.                                  long                     flags);
  207.  
  208. #endif  /* TARGET_OS_WIN32 */
  209.  
  210. /*——————————————————————————————————————————————————————————————————————————————————————*/
  211. /*    • Menu ProcPtrs                                                                     */
  212. /*                                                                                        */
  213. /*    All of these procs are considered deprecated.  Developers interested in portability    */
  214. /*    to Carbon should avoid them entirely, if at all possible.                            */
  215. /*——————————————————————————————————————————————————————————————————————————————————————*/
  216. typedef CALLBACK_API( void , MenuDefProcPtr )(short message, MenuHandle theMenu, Rect *menuRect, Point hitPt, short *whichItem);
  217. typedef CALLBACK_API( long , MenuBarDefProcPtr )(short selector, short message, short parameter1, long parameter2);
  218. typedef CALLBACK_API( void , MenuHookProcPtr )(void );
  219. typedef CALLBACK_API( short , MBarHookProcPtr )(Rect *menuRect);
  220. /*
  221.     WARNING: MBarHookProcPtr uses register based parameters under classic 68k
  222.              and cannot be written in a high-level language without 
  223.              the help of mixed mode or assembly glue.
  224. */
  225. typedef STACK_UPP_TYPE(MenuDefProcPtr)                             MenuDefUPP;
  226. typedef STACK_UPP_TYPE(MenuBarDefProcPtr)                         MenuBarDefUPP;
  227. typedef STACK_UPP_TYPE(MenuHookProcPtr)                         MenuHookUPP;
  228. typedef REGISTER_UPP_TYPE(MBarHookProcPtr)                         MBarHookUPP;
  229. enum { uppMenuDefProcInfo = 0x0000FF80 };                         /* pascal no_return_value Func(2_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  230. enum { uppMenuBarDefProcInfo = 0x00003AB0 };                     /* pascal 4_bytes Func(2_bytes, 2_bytes, 2_bytes, 4_bytes) */
  231. enum { uppMenuHookProcInfo = 0x00000000 };                         /* pascal no_return_value Func() */
  232. enum { uppMBarHookProcInfo = 0x000000CF };                         /* SPECIAL_CASE_PROCINFO(12) */
  233. #define NewMenuDefProc(userRoutine)                             (MenuDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuDefProcInfo, GetCurrentArchitecture())
  234. #define NewMenuBarDefProc(userRoutine)                             (MenuBarDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuBarDefProcInfo, GetCurrentArchitecture())
  235. #define NewMenuHookProc(userRoutine)                             (MenuHookUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuHookProcInfo, GetCurrentArchitecture())
  236. #define NewMBarHookProc(userRoutine)                             (MBarHookUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppMBarHookProcInfo, GetCurrentArchitecture())
  237. #define CallMenuDefProc(userRoutine, message, theMenu, menuRect, hitPt, whichItem)  CALL_FIVE_PARAMETER_UPP((userRoutine), uppMenuDefProcInfo, (message), (theMenu), (menuRect), (hitPt), (whichItem))
  238. #define CallMenuBarDefProc(userRoutine, selector, message, parameter1, parameter2)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppMenuBarDefProcInfo, (selector), (message), (parameter1), (parameter2))
  239. #define CallMenuHookProc(userRoutine)                             CALL_ZERO_PARAMETER_UPP((userRoutine), uppMenuHookProcInfo)
  240. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  241.     /* CallMBarHookProc can't be called from classic 68k without glue code */
  242. #else
  243.     #define CallMBarHookProc(userRoutine, menuRect)             CALL_ONE_PARAMETER_UPP((userRoutine), uppMBarHookProcInfo, (menuRect))
  244. #endif
  245. /*——————————————————————————————————————————————————————————————————————————————————————*/
  246. /*    • Menu Manager Initialization                                                        */
  247. /*——————————————————————————————————————————————————————————————————————————————————————*/
  248. EXTERN_API( void )
  249. InitProcMenu                    (short                     resID)                                ONEWORDINLINE(0xA808);
  250.  
  251. EXTERN_API( void )
  252. InitMenus                        (void)                                                        ONEWORDINLINE(0xA930);
  253.  
  254. /*——————————————————————————————————————————————————————————————————————————————————————*/
  255. /*    • Menu Manipulation                                                                     */
  256. /*——————————————————————————————————————————————————————————————————————————————————————*/
  257. EXTERN_API( MenuHandle )
  258. NewMenu                            (short                     menuID,
  259.                                  ConstStr255Param         menuTitle)                            ONEWORDINLINE(0xA931);
  260.  
  261. #if TARGET_OS_MAC
  262.     #define MacGetMenu GetMenu
  263. #endif
  264. EXTERN_API( MenuHandle )
  265. MacGetMenu                        (short                     resourceID)                            ONEWORDINLINE(0xA9BF);
  266.  
  267. EXTERN_API( void )
  268. DisposeMenu                        (MenuHandle             theMenu)                            ONEWORDINLINE(0xA932);
  269.  
  270. EXTERN_API( void )
  271. CalcMenuSize                    (MenuHandle             theMenu)                            ONEWORDINLINE(0xA948);
  272.  
  273. EXTERN_API( short )
  274. CountMItems                        (MenuHandle             theMenu)                            ONEWORDINLINE(0xA950);
  275.  
  276. /* Routines available in Mac OS 8.5 and later*/
  277.  
  278. EXTERN_API( OSStatus )
  279. GetMenuFont                        (MenuHandle             menu,
  280.                                  SInt16 *                outFontID,
  281.                                  UInt16 *                outFontSize);
  282.  
  283. EXTERN_API( OSStatus )
  284. SetMenuFont                        (MenuHandle             menu,
  285.                                  SInt16                 inFontID,
  286.                                  UInt16                 inFontSize);
  287.  
  288. EXTERN_API( Boolean )
  289. GetMenuExcludesMarkColumn        (MenuHandle             menu);
  290.  
  291. EXTERN_API( OSStatus )
  292. SetMenuExcludesMarkColumn        (MenuHandle             menu,
  293.                                  Boolean                 excludesMark);
  294.  
  295. /*——————————————————————————————————————————————————————————————————————————————————————*/
  296. /*    • Menu Item Insertion                                                                 */
  297. /*——————————————————————————————————————————————————————————————————————————————————————*/
  298. #if TARGET_OS_MAC
  299.     #define MacAppendMenu AppendMenu
  300. #endif
  301. EXTERN_API( void )
  302. MacAppendMenu                    (MenuHandle             menu,
  303.                                  ConstStr255Param         data)                                ONEWORDINLINE(0xA933);
  304.  
  305. EXTERN_API( void )
  306. InsertResMenu                    (MenuHandle             theMenu,
  307.                                  ResType                 theType,
  308.                                  short                     afterItem)                            ONEWORDINLINE(0xA951);
  309.  
  310. EXTERN_API( void )
  311. AppendResMenu                    (MenuHandle             theMenu,
  312.                                  ResType                 theType)                            ONEWORDINLINE(0xA94D);
  313.  
  314. #if TARGET_OS_MAC
  315.     #define MacInsertMenuItem InsertMenuItem
  316. #endif
  317. EXTERN_API( void )
  318. MacInsertMenuItem                (MenuHandle             theMenu,
  319.                                  ConstStr255Param         itemString,
  320.                                  short                     afterItem)                            ONEWORDINLINE(0xA826);
  321.  
  322. EXTERN_API( void )
  323. DeleteMenuItem                    (MenuHandle             theMenu,
  324.                                  short                     item)                                ONEWORDINLINE(0xA952);
  325.  
  326. EXTERN_API( void )
  327. InsertFontResMenu                (MenuHandle             theMenu,
  328.                                  short                     afterItem,
  329.                                  short                     scriptFilter)                        THREEWORDINLINE(0x303C, 0x0400, 0xA825);
  330.  
  331. EXTERN_API( void )
  332. InsertIntlResMenu                (MenuHandle             theMenu,
  333.                                  ResType                 theType,
  334.                                  short                     afterItem,
  335.                                  short                     scriptFilter)                        THREEWORDINLINE(0x303C, 0x0601, 0xA825);
  336.  
  337. /* Routines available in Mac OS 8.5 and later*/
  338.  
  339. EXTERN_API( OSStatus )
  340. AppendMenuItemText                (MenuHandle             menu,
  341.                                  ConstStr255Param         inString);
  342.  
  343. EXTERN_API( OSStatus )
  344. InsertMenuItemText                (MenuHandle             menu,
  345.                                  ConstStr255Param         inString,
  346.                                  UInt16                 afterItem);
  347.  
  348. /*——————————————————————————————————————————————————————————————————————————————————————*/
  349. /*    • Menu Events                                                                         */
  350. /*——————————————————————————————————————————————————————————————————————————————————————*/
  351. EXTERN_API( long )
  352. MenuKey                            (CharParameter             ch)                                    ONEWORDINLINE(0xA93E);
  353.  
  354. EXTERN_API( long )
  355. MenuSelect                        (Point                     startPt)                            ONEWORDINLINE(0xA93D);
  356.  
  357. EXTERN_API( long )
  358. PopUpMenuSelect                    (MenuHandle             menu,
  359.                                  short                     top,
  360.                                  short                     left,
  361.                                  short                     popUpItem)                            ONEWORDINLINE(0xA80B);
  362.  
  363. EXTERN_API( long )
  364. MenuChoice                        (void)                                                        ONEWORDINLINE(0xAA66);
  365.  
  366. /* Routines available in Mac OS 8.0 (Appearance 1.0) and later*/
  367. EXTERN_API( UInt32 )
  368. MenuEvent                        (const EventRecord *    inEvent)                            THREEWORDINLINE(0x303C, 0x020C, 0xA825);
  369.  
  370.  
  371. /*——————————————————————————————————————————————————————————————————————————————————————*/
  372. /*    • Menu Bar                                                                               */
  373. /*——————————————————————————————————————————————————————————————————————————————————————*/
  374. EXTERN_API( short )
  375. GetMBarHeight                    (void)                                                        TWOWORDINLINE(0x3EB8, 0x0BAA);
  376.  
  377. #if TARGET_OS_MAC
  378.     #define MacDrawMenuBar DrawMenuBar
  379. #endif
  380. EXTERN_API( void )
  381. MacDrawMenuBar                    (void)                                                        ONEWORDINLINE(0xA937);
  382.  
  383. EXTERN_API( void )
  384. InvalMenuBar                    (void)                                                        ONEWORDINLINE(0xA81D);
  385.  
  386. EXTERN_API( void )
  387. HiliteMenu                        (short                     menuID)                                ONEWORDINLINE(0xA938);
  388.  
  389. EXTERN_API( Handle )
  390. GetNewMBar                        (short                     menuBarID)                            ONEWORDINLINE(0xA9C0);
  391.  
  392. EXTERN_API( Handle )
  393. GetMenuBar                        (void)                                                        ONEWORDINLINE(0xA93B);
  394.  
  395. EXTERN_API( void )
  396. SetMenuBar                        (Handle                 menuList)                            ONEWORDINLINE(0xA93C);
  397.  
  398. EXTERN_API( MenuHandle )
  399. GetMenuHandle                    (short                     menuID)                                ONEWORDINLINE(0xA949);
  400.  
  401. #if TARGET_OS_MAC
  402.     #define MacInsertMenu InsertMenu
  403. #endif
  404. EXTERN_API( void )
  405. MacInsertMenu                    (MenuHandle             theMenu,
  406.                                  short                     beforeID)                            ONEWORDINLINE(0xA935);
  407.  
  408. #if TARGET_OS_MAC
  409.     #define MacDeleteMenu DeleteMenu
  410. #endif
  411. EXTERN_API( void )
  412. MacDeleteMenu                    (short                     menuID)                                ONEWORDINLINE(0xA936);
  413.  
  414. EXTERN_API( void )
  415. ClearMenuBar                    (void)                                                        ONEWORDINLINE(0xA934);
  416.  
  417. EXTERN_API( void )
  418. SetMenuFlash                    (short                     count)                                ONEWORDINLINE(0xA94A);
  419.  
  420. EXTERN_API( void )
  421. FlashMenuBar                    (short                     menuID)                                ONEWORDINLINE(0xA94C);
  422.  
  423. EXTERN_API( Boolean )
  424. SystemEdit                        (short                     editCmd)                            ONEWORDINLINE(0xA9C2);
  425.  
  426. EXTERN_API( void )
  427. SystemMenu                        (long                     menuResult)                            ONEWORDINLINE(0xA9B5);
  428.  
  429. /* Routines available in Mac OS 8.5 and later*/
  430. EXTERN_API( Boolean )
  431. IsMenuBarVisible                (void);
  432.  
  433. EXTERN_API( void )
  434. ShowMenuBar                        (void);
  435.  
  436. EXTERN_API( void )
  437. HideMenuBar                        (void);
  438.  
  439.  
  440. /*——————————————————————————————————————————————————————————————————————————————————————*/
  441. /*    • Menu Item Accessors                                                                 */
  442. /*——————————————————————————————————————————————————————————————————————————————————————*/
  443. EXTERN_API( void )
  444. CheckItem                        (MenuHandle             theMenu,
  445.                                  short                     item,
  446.                                  Boolean                 checked)                            ONEWORDINLINE(0xA945);
  447.  
  448. EXTERN_API( void )
  449. SetMenuItemText                    (MenuHandle             theMenu,
  450.                                  short                     item,
  451.                                  ConstStr255Param         itemString)                            ONEWORDINLINE(0xA947);
  452.  
  453. EXTERN_API( void )
  454. GetMenuItemText                    (MenuHandle             theMenu,
  455.                                  short                     item,
  456.                                  Str255                 itemString)                            ONEWORDINLINE(0xA946);
  457.  
  458. EXTERN_API( void )
  459. SetItemMark                        (MenuHandle             theMenu,
  460.                                  short                     item,
  461.                                  CharParameter             markChar)                            ONEWORDINLINE(0xA944);
  462.  
  463. EXTERN_API( void )
  464. GetItemMark                        (MenuHandle             theMenu,
  465.                                  short                     item,
  466.                                  CharParameter *        markChar)                            ONEWORDINLINE(0xA943);
  467.  
  468. EXTERN_API( void )
  469. SetItemCmd                        (MenuHandle             theMenu,
  470.                                  short                     item,
  471.                                  CharParameter             cmdChar)                            ONEWORDINLINE(0xA84F);
  472.  
  473. EXTERN_API( void )
  474. GetItemCmd                        (MenuHandle             theMenu,
  475.                                  short                     item,
  476.                                  CharParameter *        cmdChar)                            ONEWORDINLINE(0xA84E);
  477.  
  478. EXTERN_API( void )
  479. SetItemIcon                        (MenuHandle             theMenu,
  480.                                  short                     item,
  481.                                  short                     iconIndex)                            ONEWORDINLINE(0xA940);
  482.  
  483. EXTERN_API( void )
  484. GetItemIcon                        (MenuHandle             theMenu,
  485.                                  short                     item,
  486.                                  short *                iconIndex)                            ONEWORDINLINE(0xA93F);
  487.  
  488. EXTERN_API( void )
  489. SetItemStyle                    (MenuHandle             theMenu,
  490.                                  short                     item,
  491.                                  StyleParameter         chStyle)                            ONEWORDINLINE(0xA942);
  492.  
  493. EXTERN_API( void )
  494. GetItemStyle                    (MenuHandle             theMenu,
  495.                                  short                     item,
  496.                                  Style *                chStyle);
  497.  
  498. EXTERN_API( void )
  499. DisableItem                        (MenuHandle             theMenu,
  500.                                  short                     item)                                ONEWORDINLINE(0xA93A);
  501.  
  502. EXTERN_API( void )
  503. EnableItem                        (MenuHandle             theMenu,
  504.                                  short                     item)                                ONEWORDINLINE(0xA939);
  505.  
  506. /* Routines available in Mac OS 8.0 (Appearance 1.0) and later*/
  507.  
  508. EXTERN_API( OSErr )
  509. SetMenuItemCommandID            (MenuHandle             inMenu,
  510.                                  SInt16                 inItem,
  511.                                  UInt32                 inCommandID)                        THREEWORDINLINE(0x303C, 0x0502, 0xA825);
  512.  
  513. EXTERN_API( OSErr )
  514. GetMenuItemCommandID            (MenuHandle             inMenu,
  515.                                  SInt16                 inItem,
  516.                                  UInt32 *                outCommandID)                        THREEWORDINLINE(0x303C, 0x0503, 0xA825);
  517.  
  518. EXTERN_API( OSErr )
  519. SetMenuItemModifiers            (MenuHandle             inMenu,
  520.                                  SInt16                 inItem,
  521.                                  UInt8                     inModifiers)                        THREEWORDINLINE(0x303C, 0x0404, 0xA825);
  522.  
  523. EXTERN_API( OSErr )
  524. GetMenuItemModifiers            (MenuHandle             inMenu,
  525.                                  SInt16                 inItem,
  526.                                  UInt8 *                outModifiers)                        THREEWORDINLINE(0x303C, 0x0505, 0xA825);
  527.  
  528. EXTERN_API( OSErr )
  529. SetMenuItemIconHandle            (MenuHandle             inMenu,
  530.                                  SInt16                 inItem,
  531.                                  UInt8                     inIconType,
  532.                                  Handle                 inIconHandle)                        THREEWORDINLINE(0x303C, 0x0606, 0xA825);
  533.  
  534. EXTERN_API( OSErr )
  535. GetMenuItemIconHandle            (MenuHandle             inMenu,
  536.                                  SInt16                 inItem,
  537.                                  UInt8 *                outIconType,
  538.                                  Handle *                outIconHandle)                        THREEWORDINLINE(0x303C, 0x0707, 0xA825);
  539.  
  540. EXTERN_API( OSErr )
  541. SetMenuItemTextEncoding            (MenuHandle             inMenu,
  542.                                  SInt16                 inItem,
  543.                                  TextEncoding             inScriptID)                            THREEWORDINLINE(0x303C, 0x0408, 0xA825);
  544.  
  545. EXTERN_API( OSErr )
  546. GetMenuItemTextEncoding            (MenuHandle             inMenu,
  547.                                  SInt16                 inItem,
  548.                                  TextEncoding *            outScriptID)                        THREEWORDINLINE(0x303C, 0x0509, 0xA825);
  549.  
  550. EXTERN_API( OSErr )
  551. SetMenuItemHierarchicalID        (MenuHandle             inMenu,
  552.                                  SInt16                 inItem,
  553.                                  SInt16                 inHierID)                            THREEWORDINLINE(0x303C, 0x040D, 0xA825);
  554.  
  555. EXTERN_API( OSErr )
  556. GetMenuItemHierarchicalID        (MenuHandle             inMenu,
  557.                                  SInt16                 inItem,
  558.                                  SInt16 *                outHierID)                            THREEWORDINLINE(0x303C, 0x050E, 0xA825);
  559.  
  560. EXTERN_API( OSErr )
  561. SetMenuItemFontID                (MenuHandle             inMenu,
  562.                                  SInt16                 inItem,
  563.                                  SInt16                 inFontID)                            THREEWORDINLINE(0x303C, 0x040F, 0xA825);
  564.  
  565. EXTERN_API( OSErr )
  566. GetMenuItemFontID                (MenuHandle             inMenu,
  567.                                  SInt16                 inItem,
  568.                                  SInt16 *                outFontID)                            THREEWORDINLINE(0x303C, 0x0510, 0xA825);
  569.  
  570. EXTERN_API( OSErr )
  571. SetMenuItemRefCon                (MenuHandle             inMenu,
  572.                                  SInt16                 inItem,
  573.                                  UInt32                 inRefCon)                            THREEWORDINLINE(0x303C, 0x050A, 0xA825);
  574.  
  575. EXTERN_API( OSErr )
  576. GetMenuItemRefCon                (MenuHandle             inMenu,
  577.                                  SInt16                 inItem,
  578.                                  UInt32 *                outRefCon)                            THREEWORDINLINE(0x303C, 0x050B, 0xA825);
  579.  
  580. EXTERN_API( OSErr )
  581. SetMenuItemRefCon2                (MenuHandle             inMenu,
  582.                                  SInt16                 inItem,
  583.                                  UInt32                 inRefCon2)                            THREEWORDINLINE(0x303C, 0x0511, 0xA825);
  584.  
  585. EXTERN_API( OSErr )
  586. GetMenuItemRefCon2                (MenuHandle             inMenu,
  587.                                  SInt16                 inItem,
  588.                                  UInt32 *                outRefCon2)                            THREEWORDINLINE(0x303C, 0x0512, 0xA825);
  589.  
  590. EXTERN_API( OSErr )
  591. SetMenuItemKeyGlyph                (MenuHandle             inMenu,
  592.                                  SInt16                 inItem,
  593.                                  SInt16                 inGlyph)                            THREEWORDINLINE(0x303C, 0x0513, 0xA825);
  594.  
  595. EXTERN_API( OSErr )
  596. GetMenuItemKeyGlyph                (MenuHandle             inMenu,
  597.                                  SInt16                 inItem,
  598.                                  SInt16 *                outGlyph)                            THREEWORDINLINE(0x303C, 0x0514, 0xA825);
  599.  
  600. /* Routines available in Mac OS 8.5 and later (supporting enabling/disabling of > 31 items)*/
  601.  
  602. #if TARGET_OS_MAC
  603.     #define MacEnableMenuItem EnableMenuItem
  604. #endif
  605. EXTERN_API( void )
  606. MacEnableMenuItem                (MenuHandle             theMenu,
  607.                                  UInt16                 item);
  608.  
  609. EXTERN_API( void )
  610. DisableMenuItem                    (MenuHandle             theMenu,
  611.                                  UInt16                 item);
  612.  
  613. EXTERN_API( Boolean )
  614. IsMenuItemEnabled                (MenuHandle             menu,
  615.                                  UInt16                 item);
  616.  
  617. EXTERN_API( void )
  618. EnableMenuItemIcon                (MenuHandle             theMenu,
  619.                                  UInt16                 item)                                THREEWORDINLINE(0x303C, 0x0019, 0xA825);
  620.  
  621. EXTERN_API( void )
  622. DisableMenuItemIcon                (MenuHandle             theMenu,
  623.                                  UInt16                 item)                                THREEWORDINLINE(0x303C, 0x0020, 0xA825);
  624.  
  625. EXTERN_API( Boolean )
  626. IsMenuItemIconEnabled            (MenuHandle             menu,
  627.                                  UInt16                 item)                                THREEWORDINLINE(0x303C, 0x0018, 0xA825);
  628.  
  629.  
  630. /*——————————————————————————————————————————————————————————————————————————————————————*/
  631. /*    • Menu Item Color Tables                                                             */
  632. /*                                                                                          */
  633. /*    Menu color manipulation is considered deprecated with the advent of the Appearance    */
  634. /*    Manager.  Avoid using these routines if possible                                     */
  635. /*——————————————————————————————————————————————————————————————————————————————————————*/
  636. EXTERN_API( void )
  637. DeleteMCEntries                    (short                     menuID,
  638.                                  short                     menuItem)                            ONEWORDINLINE(0xAA60);
  639.  
  640. EXTERN_API( MCTableHandle )
  641. GetMCInfo                        (void)                                                        ONEWORDINLINE(0xAA61);
  642.  
  643. EXTERN_API( void )
  644. SetMCInfo                        (MCTableHandle             menuCTbl)                            ONEWORDINLINE(0xAA62);
  645.  
  646. EXTERN_API( void )
  647. DisposeMCInfo                    (MCTableHandle             menuCTbl)                            ONEWORDINLINE(0xAA63);
  648.  
  649. EXTERN_API( MCEntryPtr )
  650. GetMCEntry                        (short                     menuID,
  651.                                  short                     menuItem)                            ONEWORDINLINE(0xAA64);
  652.  
  653. EXTERN_API( void )
  654. SetMCEntries                    (short                     numEntries,
  655.                                  MCTablePtr             menuCEntries)                        ONEWORDINLINE(0xAA65);
  656.  
  657.  
  658.  
  659. /*——————————————————————————————————————————————————————————————————————————————————————*/
  660. /* • Properties     (Mac OS 8.5 and later)                                                    */
  661. /*                                                                                        */
  662. /* With the following property APIs, you can attach any piece of data you'd like to a    */
  663. /* menu or menu item. Passing zero for the item number parameter indicates you'd like    */
  664. /* to attach the data to the menu itself, and not to any specific menu item.            */
  665. /*——————————————————————————————————————————————————————————————————————————————————————*/
  666. EXTERN_API( OSStatus )
  667. GetMenuItemProperty                (MenuHandle             menu,
  668.                                  UInt16                 item,
  669.                                  OSType                 propertyCreator,
  670.                                  OSType                 propertyTag,
  671.                                  UInt32                 bufferSize,
  672.                                  UInt32 *                actualSize,
  673.                                  void *                    propertyBuffer);
  674.  
  675. EXTERN_API( OSStatus )
  676. GetMenuItemPropertySize            (MenuHandle             menu,
  677.                                  UInt16                 item,
  678.                                  OSType                 propertyCreator,
  679.                                  OSType                 propertyTag,
  680.                                  UInt32 *                size);
  681.  
  682. EXTERN_API( OSStatus )
  683. SetMenuItemProperty                (MenuHandle             menu,
  684.                                  UInt16                 item,
  685.                                  OSType                 propertyCreator,
  686.                                  OSType                 propertyTag,
  687.                                  UInt32                 propertySize,
  688.                                  void *                    propertyData);
  689.  
  690. EXTERN_API( OSStatus )
  691. RemoveMenuItemProperty            (MenuHandle             menu,
  692.                                  UInt16                 item,
  693.                                  OSType                 propertyCreator,
  694.                                  OSType                 propertyTag);
  695.  
  696.  
  697.  
  698. /*——————————————————————————————————————————————————————————————————————————————————————*/
  699. /*    • Contextual Menu routines and constants                                            */
  700. /*    available with Conxtextual Menu extension 1.0 and later                                */
  701. /*——————————————————————————————————————————————————————————————————————————————————————*/
  702. /* Gestalt Selector for classic 68K apps only. */
  703. /* CFM apps should weak link and check the symbols. */
  704.  
  705. enum {
  706.     gestaltContextualMenuAttr    = FOUR_CHAR_CODE('cmnu'),
  707.     gestaltContextualMenuUnusedBit = 0,
  708.     gestaltContextualMenuTrapAvailable = 1
  709. };
  710.  
  711. /* Values indicating what kind of help the application supports */
  712.  
  713. enum {
  714.     kCMHelpItemNoHelp            = 0,
  715.     kCMHelpItemAppleGuide        = 1,
  716.     kCMHelpItemOtherHelp        = 2
  717. };
  718.  
  719. /* Values indicating what was chosen from the menu */
  720.  
  721. enum {
  722.     kCMNothingSelected            = 0,
  723.     kCMMenuItemSelected            = 1,
  724.     kCMShowHelpSelected            = 3
  725. };
  726.  
  727. EXTERN_API( OSStatus )
  728. InitContextualMenus                (void)                                                        TWOWORDINLINE(0x7001, 0xAA72);
  729.  
  730. EXTERN_API( Boolean )
  731. IsShowContextualMenuClick        (const EventRecord *    inEvent)                            TWOWORDINLINE(0x7002, 0xAA72);
  732.  
  733. EXTERN_API( OSStatus )
  734. ContextualMenuSelect            (MenuHandle             inMenu,
  735.                                  Point                     inGlobalLocation,
  736.                                  Boolean                 inReserved,
  737.                                  UInt32                 inHelpType,
  738.                                  ConstStr255Param         inHelpItemString,
  739.                                  const AEDesc *            inSelection,
  740.                                  UInt32 *                outUserSelectionType,
  741.                                  SInt16 *                outMenuID,
  742.                                  UInt16 *                outMenuItem)                        TWOWORDINLINE(0x7003, 0xAA72);
  743.  
  744. EXTERN_API( Boolean )
  745. ProcessIsContextualMenuClient    (ProcessSerialNumber *    inPSN)                                TWOWORDINLINE(0x7004, 0xAA72);
  746.  
  747.  
  748.  
  749.  
  750. /* 
  751.     CheckItem, CountMItems, and SetMenuFlash should have better names.
  752.     But the shipping InterfaceLib has the old names, so we need
  753.     to define the new and old names and use macros to map the 
  754.     new names to old names for linking with InterfaceLib.
  755. */
  756. #if TARGET_OS_MAC
  757.     #define CheckMenuItem MacCheckMenuItem
  758. #endif
  759. #define MacCheckMenuItem( menu, item, checked ) CheckItem( menu, item, checked )
  760. #define CountMenuItems( menu )                     CountMItems( menu )
  761. #define SetMenuFlashCount( count )                 SetMenuFlash( count )
  762.  
  763.  
  764. #if CGLUESUPPORTED
  765. EXTERN_API_C( MenuHandle )
  766. newmenu                            (short                     menuID,
  767.                                  const char *            menuTitle);
  768.  
  769. EXTERN_API_C( void )
  770. appendmenu                        (MenuHandle             menu,
  771.                                  const char *            data);
  772.  
  773. EXTERN_API_C( void )
  774. insertmenuitem                    (MenuHandle             theMenu,
  775.                                  const char *            itemString,
  776.                                  short                     afterItem);
  777.  
  778. EXTERN_API_C( long )
  779. menuselect                        (const Point *            startPt);
  780.  
  781. EXTERN_API_C( void )
  782. setmenuitemtext                    (MenuHandle             menu,
  783.                                  short                     item,
  784.                                  const char *            itemString);
  785.  
  786. EXTERN_API_C( void )
  787. getmenuitemtext                    (MenuHandle             menu,
  788.                                  short                     item,
  789.                                  char *                    itemString);
  790.  
  791. #endif  /* CGLUESUPPORTED */
  792.  
  793. #if OLDROUTINENAMES
  794. #define AddResMenu(theMenu, theType) AppendResMenu(theMenu, theType)
  795. #define InsMenuItem(theMenu, itemString, afterItem)    InsertMenuItem(theMenu, itemString, afterItem)
  796. #define DelMenuItem( theMenu, item ) DeleteMenuItem( theMenu, item )
  797. #if TARGET_OS_MAC
  798. #define SetItem MacSetItem
  799. #define GetItem MacGetItem
  800. #endif
  801. #define MacSetItem(theMenu, item, itemString) SetMenuItemText(theMenu, item, itemString)
  802. #define MacGetItem(theMenu, item, itemString) GetMenuItemText(theMenu, item, itemString)
  803. #define GetMHandle(menuID) GetMenuHandle(menuID)
  804. #define DelMCEntries(menuID, menuItem) DeleteMCEntries(menuID, menuItem)
  805. #define DispMCInfo(menuCTbl) DisposeMCInfo(menuCTbl)
  806. #if CGLUESUPPORTED
  807. #define addresmenu(menu, data) appendresmenu(menu, data)
  808. #define getitem(menu, item, itemString) getmenuitemtext(menu, item, itemString)
  809. #define setitem(menu, item, itemString) setmenuitemtext(menu, item, itemString)
  810. #define insmenuitem(theMenu, itemString, afterItem)    insertmenuitem(theMenu, itemString, afterItem)
  811. #endif    /* CGLUESUPPORTED */
  812. #endif  /* OLDROUTINENAMES */
  813.  
  814.  
  815.  
  816. #if TARGET_OS_WIN32
  817. #endif  /* TARGET_OS_WIN32 */
  818.  
  819.  
  820. #if PRAGMA_STRUCT_ALIGN
  821.     #pragma options align=reset
  822. #elif PRAGMA_STRUCT_PACKPUSH
  823.     #pragma pack(pop)
  824. #elif PRAGMA_STRUCT_PACK
  825.     #pragma pack()
  826. #endif
  827.  
  828. #ifdef PRAGMA_IMPORT_OFF
  829. #pragma import off
  830. #elif PRAGMA_IMPORT
  831. #pragma import reset
  832. #endif
  833.  
  834. #ifdef __cplusplus
  835. }
  836. #endif
  837.  
  838. #endif /* __MENUS__ */
  839.  
  840.